package net.wanho.zaixian.course.controller;

import com.alibaba.fastjson.JSONObject;
import net.wanho.zaixian.course.service.CategoryService;
import net.wanho.zaixian.pojo.course.ext.CategoryNode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    @GetMapping("/category/list")
    public JSONObject getCategoryList(){
        List<CategoryNode> allCategory = categoryService.getAllCategory();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("children",allCategory);

        return jsonObject;
    }
}
